import 'package:flutter/material.dart';
import 'package:flutter_demo/chapter8-EventNotification/event-mechanism/HitTestBlocker.dart';
import 'package:flutter_demo/chapter8-EventNotification/gesture-conflict/CustomTapGestureRecongnizer.dart';

void main() {
  runApp(MaterialApp(
    home: Scaffold(
      appBar: AppBar(
        title: const Text("Notification Widget Demo"),
      ),
      body: NotificationListenerWidget(),
    ),
  ));
}

class NotificationListenerWidget extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return NotificationListener(
      onNotification: (notification){
        switch (notification.runtimeType){
          case ScrollStartNotification: print("开始滚动"); break;
          case ScrollUpdateNotification: print("正在滚动"); break;
          case ScrollEndNotification: print("滚动停止"); break;
          case OverscrollNotification: print("滚动到边界"); break;
        }
        return true;
      },
      child: ListView.builder(
          itemCount: 100,
          itemBuilder: (context, index) {
            return ListTile(title: Text("$index"),);
          }
      ),
    );
  }
}